package com.yt.system.utils;

import org.springframework.web.multipart.MultipartFile;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.UUID;

public class PhotoUtil {

    public static String putPic(MultipartFile file){
        String fileName = UUID.randomUUID() + file.getOriginalFilename();
        File dest = new File(fileName);
        try{
            file.transferTo(dest);
        }catch(Exception e){
            e.printStackTrace();
            System.out.println("上传失败");
        }
        System.out.println("上传成功");
        String nameAndHost = "/usr/local/java/ytsystem" + fileName;
        return nameAndHost;
    }
    public static String putPhoto(MultipartFile file,Integer uid){
        String fileName = uid+".jpg";
        System.out.println(fileName);
        File dest = new File(fileName);
        try{
            file.transferTo(dest);
        }catch(Exception e){
            e.printStackTrace();
            System.out.println("上传失败");
        }
        System.out.println("上传成功");
        String nameAndHost = "/usr/local/java/ytsystem/" + fileName;

        return nameAndHost;
    }

}
